/**
 * 功能描述 导航栏
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper")
	var store =require("store");
	var planfile = require("../store/planfile");
	var activeUser = store.get("user");
	
    var instance = {
        initComponent:function (params,widget){
        	var subnav=new Subnav({
        		parentNode:".J-subnav",
        		model:{
            		title:"意向客户档案",
            		items:[{
        				id:"search",
        				type:"search",
        				placeholder:"姓名/电话/证件号",
        				handler:function(str){
        					var grid=widget.get("grid");
        					aw.ajax({
        						url:"api/customer/search",
        						data:{
        							s:str,
        							properties:"personalInfo.name,personalInfo.mobilePhone,personalInfo.idNumber",
        							"dataSourceIn" : "NoMember,Visit",
        							"saleConsultant": activeUser.pkUser,
        							fetchProperties:planfile.fetchProperties
        						},
        						dataType:"json",
        						success:function(data){
        							grid.setData(data);
        						}
        					});
        				}
        			},{
            			 id:"dataSource",
			   			 tip:"客户类型",
			   			 type:'buttongroup',
						 items:[{
							 	key :"NoMember,Visit",
								value:"全部"
						 },{
								key :"NoMember",
								value:"体验客户"
						 },{
								key :"Visit",
								value:"意向客户"
						 }],
            			handler:function(key,element){
    						widget.get("grid").refresh();
    					}
            		},{
            			id:"return",
    					type:"button",
    					text:"返回",
    					show:false,
    					handler:function(){
    						widget.hide([".J-form"]).show([".J-grid"]);
    						widget.get("subnav").hide(["return"]).show(["dataSource","search"]);
    					}
            		}]
        		}
        	});
        	widget.set("subnav",subnav);

        }
    };
    module.exports = instance;
});
